package com.utils.email;

import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import org.thymeleaf.context.Context;
import org.thymeleaf.spring5.SpringTemplateEngine;

@Component
public class SendEmailUtil {

    @Resource
    private SpringTemplateEngine springTemplateEngine;
    @Resource
    private EmailService emailService;
    public void sendEmail(String mail,String mess){
        Context context = new Context();
        context.setVariable("verificationCode",mess);
        String sendCodeEmail = springTemplateEngine.process("send_code_email", context);
        Email email = new Email();
        email.setSendTo(mail);
        email.setContent(sendCodeEmail);
        email.setSubject("邮件内容");
        emailService.sendMail(email);

    }
}
